<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>作者简介页面</title>
		<script src="http://47.106.66.89:8080/js/vue.min.js"></script>
		<script src="http://47.106.66.89:8080/js/axios.min.js"></script>
		<link  href="http://47.106.66.89:8080/js/ele-2.15.7/theme-chalk/index.css" rel="stylesheet">
			<script src="http://47.106.66.89:8080/js/ele-2.15.7/index.js"></script>
			 
			<link href="css/index.css" rel="stylesheet" type="text/css"/>
			<link href="css/novel.css" rel="stylesheet" type="text/css"/>
		<link href="css/select.css" rel="stylesheet" type="text/css"/>



	</head>
	<body>
		
		
		<div id="app">
			<div class="td-header" :class="{ 'is-sticky': isSticky }">
				
				<div class="td-header-content">
					<div class="td-header-logo">
						<img src="image/logo.png" />
						<li> 土豆小说网 </li>
					</div>
					<div class="td-header-right">
						<div class="right-shouye">
							<a href="index.html">首页</a>
							 
						</div>
						<div class="right-shouye">
							<a href="bookstore.html">书库</a>
							 
						</div>
						<div class="right-shouye">
							<a href="bookshelf.html">书架</a>
							 
						</div>
						<div class="right-shouye">
							<a href="ranking.html">排行榜</a>
							 
						</div>

						 <div class="serial-divider  byte-divider byte-divider-vertical" style="margin-right: 40px;"></div>
						 <div class="right-user">
							 <a  v-if="!isLogged" href="login.html"> <div class="user-login">登录</div></a>
							 <a v-if="!isLogged" href="login.html"><div class="user-reg">注册</div></a>
							 <div v-if="isLogged" style="display: flex; align-items: center;">
								 <el-avatar icon="el-icon-user-solid" :src="this.user.avatar"> </el-avatar>
								 <span style="margin-left: 10px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis; width: 100px; ">{{this.user.username}} </span>
							 </div>
							 <div v-if="isLogged" style="display: flex; align-items: center;">
								 <span class="user-logout" @click="logout()" style="margin-left: 10px;white-space: nowrap;overflow: hidden;text-overflow: ellipsis; width: 100px;cursor: pointer; ">退出 </span>
							 </div>
						 </div>
						 
		 
						 
					</div>
				</div>
			</div>
			
			<div class="td-novel">
				<div class="muye-search">
					<div class="muye-search-wrap">
						<div class="muye-search-bar" style="height: 30px;">
							<div class="search-content">
								<img style="width: 17px;height: 20px;" src="https://ziyilin.oss-cn-shanghai.aliyuncs.com/%E6%90%9C%E7%B4%A2.png" />
								<input class="search-input" placeholder="请输入搜索内容"  v-model="selectneirou">
								<h1 class="search-title-tag"></h1>
							</div>
							<button  @click="searchLucene()" class="byte-btn byte-btn-primary byte-btn-size-large byte-btn-shape-square muye-button search-btn" type="button">
								<span>搜索</span>
							</button>
						</div>

						<div class="muye-search-hint">
							共 <span class="count">{{novelList.length}}</span> 项相关的结果
						</div>
						<div v-for="n in novelList" class="muye-search-book-list">
							<div class="search-book-item">
								<div class="muye-book-cover book-item-cover is-book has-hover">
									<div class="book-cover" style="border-radius: 5px;">
										<img class="book-cover-img  loaded" :src="n.coverImage" :alt="n.title">
										<div class="book-effect book-animate-effect"></div>
									</div>
								</div>
								<div class="book-item-text">
									<div class="title font-DNMrHsV173Pd4pgy">
										<span class="highlight-text">{{n.title}}</span>
									</div>
									<div class="desc font-DNMrHsV173Pd4pgy">
										<span>作者：
											<span class="highlight-text">{{n.authorName}}</span>
										</span>
										<span  v-if="n.statu == 0" class="span">已完结 ·  {{n.categoryName}}</span>
										<span  v-if="n.statu == 1" class="span">连载中 ·  {{n.categoryName}}</span>
										<span class="span">{{n.wordCount}}万字 </span>
									</div>
									<div class="desc abstract font-DNMrHsV173Pd4pgy">
										<span class="highlight-text">{{n.introduction}}</span>
									</div>
									<div class="footer">
										<span class="chapter">
											最近更新：{{n.chapterTitle}}
										</span>
										<span>{{n.publishDatezuixin}}</span>
									</div>
								</div>
								<button @click="Jump(n.novelId)" class="byte-btn byte-btn-text byte-btn-size-large byte-btn-shape-square muye-button book-item-btn" type="button">
									<span>立即阅读</span>
								</button>
							</div>
						</div>

					</div>
				</div>

			</div>
			
			<div class="td-footer">
				  <p>Company Name</p>
				 <p>Address: 123 Street, City, Country</p>
				 <p>Email: info@example.com</p>
			</div>
		</div>
	</body>
	
	<script>
	
	
	var v = new Vue({
		el : "#app",
		data() {
			  
			 return {
				  isSticky: false,

				 user:{
					 userId: '',
					 username: '',
					 avatar: '',
				 },

				 isLogged: false,
				 selectneirou:'',
				 novelList:[],

				   
				};
			},
	    mounted() {
			window.addEventListener('scroll', this.handleScroll);

			 this.iflogin();
			 this.getselectneirou();
			 this.indexlucene();


		},
		methods: {
			handleScroll() {
				const scrollHeight = window.scrollY || document.documentElement.scrollTop;
				const threshold = 50;
	
				this.isSticky = scrollHeight > threshold;
			},

			//判断是否登录
			iflogin(){
				axios.get('/user/iflogin').then(res=>{


					if(res.data != ""){
						this.user.userId = res.data
						axios.get('/user/getUser?userId='+this.user.userId).then(res=>{
							this.user = res.data;
						});
						this.isLogged =  true;
					}

				});

			},
			//退出登录
			logout(){
				axios.post('/user/logout').then(res=>{
					this.isLogged = false;
					this.iflogin();
					window.location.href = "index.html";

				});

			},
			//从redis中获取其他页面搜索内容
			getselectneirou(){
				axios.post('/other/select/getselectneirou').then(res=>{
					this.selectneirou = res.data;


				});
			},
			//获取数据库信息  生成 索引文件
			indexlucene(){
				axios.get('/lucene/lucene/indexLucene').then(res=>{
					this.searchLucene();
				});
			},
			//搜索
			searchLucene(){
				if (this.selectneirou != '' && this.selectneirou != null){
					axios.get('/lucene/lucene/searchLucene?selectneirou='+this.selectneirou).then(res=>{
						if(res.data){
							this.novelList = res.data;
						}

					});
				}
				else{
					this.novelList = [];
				}

			},
			//跳转到详情页
			Jump(novelId) {
				window.location.href = "novel.html#"+novelId;
			}




		}
		 
		 
		 
	})
	</script>
</html>
